{smcl}
{* 02Nov2002}{...}
{hline}
help for {hi:overid9}
{hline}

{title:Calculate tests of overidentifying restrictions after {cmd:ivreg2}, {cmd:ivreg29}, {cmd:ivregress}, {cmd:ivprobit}, {cmd:ivtobit}, {cmd:reg3}}

{p 8 14}{cmd:overid9}{bind: [, {cmd:chi2}} {cmd:dfr} {cmd:f} {cmd:all} {cmd:depvar(}{it:varname}{cmd:)}]

{p}{cmd:overid9} is part of the {cmd:overid} package and is compatible with Stata 9 and upwards.
{cmd:overid9} may be used after IV estimation with
{cmd:aweight}s, {cmd:fweight}s and {cmd:iweight}s;
see help {help weights}. {cmd:overid9} cannot be used following estimation
with factor variables in the list of explanatory variables.


{title:Description}

{dlgtab:Instrumental variables regression}

{p}{cmd:overid9} computes versions of Sargan's (1958) and Basmann's (1960)
tests of overidentifying restrictions for a 
regression estimated via instrumental variables in which the number of 
instruments exceeds the number of regressors:
that is, for an overidentified equation.
These are tests of the joint null hypothesis that
the excluded instruments are valid instruments,
i.e., uncorrelated with the error term and correctly excluded
from the estimated equation.
A rejection casts doubt on the validity of the instruments.

{p}For single-equation (limited-information) instrumental variables regression 
(as implemented in {cmd:ivreg2}, {cmd:ivreg29}) or  {cmd:ivregress}, 
write the full set of instruments as Z and
the residuals from the IV estimation as u,
let P represent the "projection matrix" Z*inv(Z'Z)*Z',
and let M=I-P, where I is the identity matrix.
N is the number of observations, L the number of instruments,
K the number of regressors,
and L-K the number of overidentifying restrictions.
Then

Sargan's (1958) statistic = u'Pu / (u'u/N)

Basmann's (1960) statistic = u'Pu / (u'Mu/(N-L))

{p}The statistics share the same numerator.  The denominators
can be interpreted as two different estimates of the error
variance of the estimated equation, both of which
are consistent (see Davidson and MacKinnon (1993), pp. 235-36).

{p}Both statistics are distributed as chi-square with L-K degrees of freedom.
Both can be calculated via an artificial regression
of the residuals of the IV estimation regressed on the
full set of instruments;
the Sargan statistic is N * the uncentered R-sq from this regression.
See, e.g., Davidson and MacKinnon (1993), p. 236 and Wooldridge
(2002), p. 123. 

{p}If there are no overidentifying restrictions (i.e., in the case of exact 
identification, where the number of excluded instruments equals the number of 
right-hand endogenous variables), an error message is printed.

{p}The version of this test that is robust to heteroskedasticity
in the errors is Hansen's J statistic;
under the assumption of conditional homoskedasticity,
Sargan's statistic becomes Hansen's J (see Hayashi (2000), p. 227-28),
and hence the two statistics are sometimes referred to
as the Hansen-Sargan statistic.
Robust overidentification statistics are available via
{cmd:ivreg2}. {cmd:overid9} will not produce a result
if either the {cmd:robust} or {cmd:cluster} options
are employed in the preceding IV regression.
{cmd:ivreg2} also provides "diff-Sargan" or "C" tests for the endogeneity of a subset of 
instruments; see help {help ivreg2} (if installed) for details.

{p}The test will fail to run if N<L. For Z'Z to be of full rank, N>L.

{dlgtab :Instrumental variables probit and Tobit}

{p}{cmd:overid9} will report an overidentification statistic after estimation by
{cmd:ivprobit} and {cmd:ivtobit} with the twostep option.  These Stata
commands request Newey's (1987) minimum-distance (or
minimum-chi-squared) IV probit and IV Tobit estimators, respectively.
Lee (1992) shows that the minimized distance for these estimators
provides a test of overidentifying restrictions.  Like Sargan and
Basmann single-equation statistics, the test statistic is distributed as
Chi-squared with (L-K) degrees of freedom under the null that the
instruments are valid.  The test statistic is available after twostep
estimation only.

{dlgtab:Three-stage least squares}

{p}{cmd:overid9} will report an overidentification statistic after system estimation
with {cmd:reg3}. As Davidson and MacKinnon (2004, p.532) indicate, a Hansen-Sargan
test of the overidentifying restrictions is based on the 3SLS criterion function
evaluated at the 3SLS point and interval parameter estimates. Under the null
hypothesis, the statistic is distributed Chi-squared wih (G*L - K) degrees of
freedom, where G is the number of simultaneous equations. The procedure will take
proper account of linear constraints on the parameter vector imposed during 
estimation. 

{dlgtab:General comments}

{p}The command displays the test statistics, degrees of freedom and P-value,
and places values in the return array. {cmd:return list} for details.

{p}A full discussion of these computations and related topics
can be found in Baum, Schaffer, and Stillman (2003) and Baum, Schaffer and
Stillman (2006). A version of this routine by Schaffer and Stillman 
that works in the context of panel data is available as {cmd:xtoverid}.


{dlgtab:Citation}

{p}{cmd:overid9} is part of the {cmd:overid} package.
It is not an official Stata command, but a free contribution
to the research community, like a paper. Please cite it as such: {p_end}
{phang}Baum, C.F., Schaffer, M.E., Stillman, S., Wiggins, V.  2006.
overid: Stata module to calculate tests of overidentifying restrictions after
ivreg, ivreg2, ivprobit, ivtobit, reg3. http://ideas.repec.org/c/boc/bocode/s396802.html{p_end}

{title:Options}

{p}Options {cmd:chi2}, {cmd:dfr}, {cmd:f} and {cmd:all} only pertain to use
of {cmd:overid} after {cmd:ivreg} or {cmd:ivreg2}.

{p 0 4}{cmd:chi2} requests Sargan's and Basmann's chi-squared statistics;
this is the default.

{p 0 4}{cmd:dfr} is equivalent to {cmd:chi2} except that the
the Sargan statistic has a small-sample correction:
u'Pu / (u'u/(N-K))

{p 0 4}{cmd:f} requests the pseudo-F test versions of
the Sargan and Basmann statistics.{p_end}
{p 4 4}Sargan pseudo-F  = u'Pu/(L-K) / (u'u/(N-K)){p_end}
{p 4 4}Basmann pseudo-F = u'Pu/(L-K) / (u'Mu/(N-L)){p_end}

{p 0 4}{cmd:all} causes all five statistics to be reported.

{p 0 4}{cmd:depvar} must be used after {cmd:ivprobit}, version 1.1.8 or earlier (Stata 9),
to specify the dependent variable of the estimated equation.

{title:Examples}

{phang}{stata "sysuse auto" : . sysuse auto}

{phang}{stata "ivreg price mpg (weight turn=length displacement gear_ratio trunk)" : . ivreg price mpg (weight turn=length displacement gear_ratio trunk)}

{phang}{stata "overid9" : . overid9}

{phang}{stata "overid9, all" : . overid9, all}

{phang}{stata "ivprobit foreign displacement (mpg=length weight turn), twostep" : . ivprobit foreign displacement (mpg=length weight turn), twostep}

{phang}{stata "overid9" : . overid9}

{phang}{stata "ivtobit gear_ratio displacement (mpg=length weight turn) [fw=rep78], twostep ll(2.2)": . ivtobit gear_ratio displacement (mpg=length weight turn) [fw=rep78], twostep ll(2.2)} 

{phang}{stata "overid9" : . overid9}

{phang}{stata "webuse klein" : . webuse klein}

{phang}{stata "constraint define 1 [consump]wagepriv = [consump]wagegovt" : . constraint define 1 [consump]wagepriv = [consump]wagegovt}

{phang}{stata "constraint define 2 [consump]govt = [wagepriv]govt" : . constraint define 2 [consump]govt = [wagepriv]govt}

{phang}{stata "reg3 ( consump wagepriv wagegovt govt invest) ( wagepriv consump govt capital1 taxnetx)": . reg3 ( consump wagepriv wagegovt govt invest) ( wagepriv consump govt capital1 taxnetx)}

{phang}{stata "overid9" : . overid9}

{phang}{stata "reg3 ( consump wagepriv wagegovt govt invest) ( wagepriv consump govt capital1 taxnetx), c(1 2)": . reg3 ( consump wagepriv wagegovt govt invest) ( wagepriv consump govt capital1 taxnetx), c(1 2)}

{phang}{stata "overid9" : . overid9}

{title:Acknowledgements}

{p 0 4} We are grateful to Austin Nichols for providing a better version of the reg3 code 
which greatly reduces memory use. Martin Weiss was also helpful in pointing out a recent bug
in official ivtobit which was causing overid to fail.

{title:References}

{p 0 4} Basmann, R.L., On Finite Sample Distributions of Generalized Classical
Linear Identifiability Test Statistics.  Journal of the American Statisical
Association, Vol. 55, Issue 292, December 1960, pp. 650-59.

{p 0 4}Baum, C. F., Schaffer, M. E., Stillman, S., Instrumental variables and GMM:
Estimation and testing. Stata Journal, Vol. 3, 2003, pp. 1-31. Available as Working Paper no. 545,
Boston College Department of Economics. http://fmwww.bc.edu/ec-p/WP545.pdf

{p 0 4}Baum, C. F., Schaffer, M. E., Stillman, S., 2006. Enhanced routines for 
instrumental variables/GMM estimation and testing. Unpublished working paper,
forthcoming.

{p 0 4} Davidson, R. and MacKinnon, J., Estimation and Inference in Econometrics.
1993. New York: Oxford University Press.

{p 0 4} Davidson, R. and MacKinnon, J., Econometric Theory and Methods.
2004. New York: Oxford University Press.

{p 0 4}Hayashi, F., Econometrics.  2000.  Princeton: Princeton University Press.

{p 0 4}Lee, L., Amemiya's Generalized Least Squares and Tests of
Overidenfication in Simultaneous Equation Models with Qualitative or
Limited Dependent Variables. Econometric Reviews, Vol. 11, No. 3, 1992,
pp. 319-328.

{p 0 4}Newey, W.K., Efficient Estimation of Limited Dependent Variable
Models with Endogeneous Explanatory Variables". Journal of Econometrics,
Vol. 36, 1987, pp. 231-250.

{p 0 4}Sargan, J.D. The Estimation of Economic Relationships Using Instrumental
Variables.  Econometrica, Vol. 26, 1958, pp. 393-415.

{p 0 4}Wooldridge, J.M., Econometric Analysis of Cross Section and Panel Data.
2002. Cambridge, MA: MIT Press.

{title:Authors}

	Christopher F Baum, Boston College, USA
	baum@bc.edu
	
	Mark E Schaffer, Heriot-Watt University, UK
	m.e.schaffer@hw.ac.uk

	Steven Stillman, Motu, New Zealand
	stillman@motu.org.nz
	
	Vince Wiggins, Stata Corporation, USA
	vwiggins@stata.com


{title:Also see}

{p 1 14}Manual:  {hi:[R] ivreg}, {hi:[R] ivprobit}, {hi:[R] ivtobit}, {hi:[R] reg3}{p_end}
{p 0 19}On-line:  help for {help overid}; {help xtoverid}; {help ivregress}; {help ivreg2} (if installed); {help ivprobit};
{help ivtobit}; {help reg3}{p_end}
